#include "GameOpt.h"

Cell::Cell()
{
	Type = 0;
	pEntity = NULL;
}

Cell::~Cell()
{
}

char Cell::isPresent() const //check if the cell type is one of the known Presents
{
	if (Type==PERESENT_TYPE_HEALTH ||
		Type==PERESENT_TYPE_HEALTH_MAX ||
		Type==PERESENT_TYPE_MOVMENT ||
		Type==PERESENT_TYPE_MOVMENT_MAX ||
		Type==PERESENT_TYPE_POWER ||
		Type==PERESENT_TYPE_DEFENCE)
		return Type;
	else
		return 0;
}

bool Cell::isWall() const
{
	return (Type == '*');
}

char Cell::isHuman() const
{
	if(!pEntity) //if there is no Entity at all
		return false;
	if(pEntity->kind() == KIND_HUMAN)//if the the Entity kind is Human
		return pEntity->getcToken();
	else
		return false;
}
char Cell::isMonster() const
{
	if(!pEntity)//if there is no Entity at all
		return false;
	if(pEntity->kind() == KIND_MONSTER)//if the the Entity kind is Monster
		return pEntity->getcToken();
	return false;
}
char Cell::GetType() const
{
	return Type;
}

bool Cell::SetType(char inType)
{
	if(inType!=KIND_HUMAN && inType != KIND_MONSTER)// if the type is unknown
		return false; 
	Type = inType;
	return true;
}

bool Cell::SetpEntity(Entity *inpEntity)
{
	pEntity= inpEntity;
	return true;
}
Entity* Cell::getPEntity() const
{
	return pEntity;
}
bool Cell::SaveState(ofstream & FileName)
{
	FileName.write(reinterpret_cast<char*>(this), sizeof(*this));

	return 1;
}

bool Cell::LoadState(ifstream & FileName)
{
	FileName.read(reinterpret_cast<char*>(this), sizeof(*this));
	pEntity=NULL;
	return 1;
}